<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="btn">Button</button>
    <script>
        let btn = document.getElementById('btn')
        btn.addEventListener('click', () => {
            var textarea = document.createElement('textarea')
            document.body.appendChild(textarea);
            textarea.style.position = 'absolute';
            textarea.style.clip = 'rect(0 0 0 0)'
            textarea.value = 'copy的内容'

            console.log(textarea.select());
            console.log(111);
            document.execCommand('copy');
        })
    </script>
</body>

</html>